package Demo08.Demo0816;

import java.util.Random;
import java.util.Scanner;
//完善猜数字游戏  让玩家能够自己判断继续玩还是结束
public class caishuzi {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Random ran = new Random();
        int a = ran.nextInt(100) + 1;
        while(true){
            System.out.println("请随机输入一个在0~100间的数字：");
            int b = sc.nextInt();
            if(a > b){
                System.out.println("你猜的太小了");
            }else if (a < b){
                System.out.println("你猜的太大了");
            }else{
                System.out.println("恭喜你，猜对了");
                break;
            }
            System.out.println("按1继续游戏   按2结束游戏");
            int c = sc.nextInt();
            if(c == 1){
                continue;
            }else if( c == 2){
                break;
            }
        }
    }
}
